﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<!--#include file="admin_inc/admin.sqlfunction.asp" -->
<%
'作者：山林客（ah_bill）
'博客：http://ruizhinet.blog.163.com
'网站：http://www.ruizhinet.cn
'本信息不会影响您网站的正常访问，请保留
checkadmin(4)
dim id,pid,strid,rsp,sqlp,recordcount
id=GetIntQueryString("id")
pid=GetIntQueryString("pid")
strid=","&CStr(id)&"," 
Set rsp = Server.CreateObject("ADODB.Recordset")
sqlp = "select count(id) as recordcount from [c_type] where parentid="&pid&""
rsp.open sqlp,conn,1,1
If Not rsp.eof Then
recordcount=rsp("recordcount")
End If 
rsp.close
Set rsp=Nothing
If recordcount=1 Then 
conn.execute("update [c_type] set havechild=0 where id="&pid)
End If 

Dim tfenlei,tpath,tpre,rpre,ttable,filepath
tfenlei=GetTypeProperty(id,"fenlei")
tpath=Replace(CutPath(GetTypeProperty(id,"path")),",","-")
Select Case tfenlei
	Case 1: 
		tpre=RZ_PRE_ARTICLE_LIST
		rpre=RZ_PRE_ARTICLE_SHOW
		ttable="c_article"
	Case 2: 
		tpre=RZ_PRE_PRODUCT_LIST
		rpre=RZ_PRE_PRODUCT_SHOW
		ttable="c_product"
	Case 3: 
		tpre=RZ_PRE_PHOTO_LIST
		rpre=RZ_PRE_PHOTO_SHOW
		ttable="c_photo"
	Case 6:
		tpre=RZ_PRE_TYPE_SHOW
	Case 7: 
		tpre=RZ_PRE_JOB_LIST
		rpre=RZ_PRE_JOB_SHOW
		ttable="c_job"
End Select 

If tfenlei=1 Or tfenlei=2 Or tfenlei=3 Or tfenlei=7 Then 
	Dim sqlt,rst,rcount1,rcount2
	rcount1=0
	rcount2=0
	Set rst = Server.CreateObject("ADODB.Recordset")
	sqlt = "select lang,count(id) as rcount from ["&ttable&"]   where Instr(path,'"&strid&"')>0 group by lang"
	rst.open sqlt,conn,1,1
	If Not rst.eof Then 
	If rst("lang")=0 Then 
	rcount1=rst("rcount")
	Else
	rcount2=rst("rcount")
	End If 
	End If 
	rst.close
	Set rst=Nothing 

	Dim lastpage1,lastpage2,ci
	lastpage1=CaculatePage(rcount1,GetTypeProperty(id,"perpage"))
	lastpage2=CaculatePage(rcount2,GetTypeProperty(id,"perpage"))
	filepath=RZ_HTML_PATH&"/"&tpre&"0/t"&tpath&".html"
	Call DeleteHtml(filepath)
	filepath=RZ_HTML_PATH&"/"&tpre&"1/t"&tpath&".html"
	Call DeleteHtml(filepath)
	For ci=1 To lastpage1 
	filepath=RZ_HTML_PATH&"/"&tpre&"0/t"&tpath&"p"&ci&".html"
	Call DeleteHtml(filepath)
	Next 
	For ci=1 To lastpage2 
	filepath=RZ_HTML_PATH&"/"&tpre&"1/t"&tpath&"p"&ci&".html"
	Call DeleteHtml(filepath)
	Next 

	Call DeleteFolder(RZ_HTML_PATH&"/"&rpre&"0/t"&tpath)
	Call DeleteFolder(RZ_HTML_PATH&"/"&rpre&"1/t"&tpath)

	conn.Execute("delete from ["&ttable&"] where Instr(path,'"&strid&"')>0")
End If 

If tfenlei=6 Then 
	filepath=RZ_HTML_PATH&"/"&tpre&"0/t"&tpath&".html"
	Call DeleteHtml(filepath)
	filepath=RZ_HTML_PATH&"/"&tpre&"1/t"&tpath&".html"
	Call DeleteHtml(filepath)
End If 

conn.Execute("delete from [c_type] where Instr(path,'"&strid&"')>0")
Call SetTypeProperties()
response.redirect("showmsg.asp?from=type_list.asp&msg=RemoveSuccess")

%>